package cn.zyq.ykb.system.enums;

import cn.zyq.ykb.system.enums.core.ResponseCodeEnum;
import cn.zyq.ykb.system.exception.BusinessException;

/**
 * 微信支付模块类型 1 充值， 2 活动投票， 3 活动礼物
 */
public enum WxPayModuleTypeEnum {
    RECHARGE("充值", "1"),
    ACTIVITY_VOTE("活动投票", "2"),
    ACTIVITY_GIFT("活动礼物", "3"),
    ;
    private String key;
    private String value;

    private WxPayModuleTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static String getKeyByValue(String value) {
        for (WxPayModuleTypeEnum item : WxPayModuleTypeEnum.values()) {
            if (item.value.equals(value)) return item.key;
        }
        throw new BusinessException(ResponseCodeEnum.ERROR.ERROR, "无效的value值");
    }

    public String getValue() {
        return value;
    }

    public String getKey() {
        return key;
    }

}
